package spring.core.aop.aspectj;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

/**
 * @author 1203056
 * @version Id: TeacherAspect.java, v 0.1 2021-09-07 9:44 1203056 Exp $
 */
@Aspect
public class TeacherAspect {

    @Pointcut("execution(public * spring.core.aop.TeacherService.*(..))")
    private void pointcut() {
    }

    @Before("pointcut()")
    public void before() {
        //获取当前调用的方法
        System.out.println("invoke before method: " + AspectContext.currentMethod());
    }

    @After("pointcut()")
    public void after() {
        System.out.println("invoke after method: " + AspectContext.currentMethod());
    }

    @Around("pointcut()")
    public void around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("teacher aspect  around :" + joinPoint.getSignature());
        joinPoint.proceed(joinPoint.getArgs());
    }

}
